package com.tiantian.quanminxiu.presenter;

import com.shenglian.utils.utils.CommonUtils;
import com.tiantian.quanminxiu.api.AnchorService;
import com.tiantian.quanminxiu.utils.ApplicationBase;
import com.tiantian.quanminxiu.utils.Constants;
import com.tiantian.quanminxiu.utils.UserData;
import com.tiantian.quanminxiu.view.PhoneLiveView;

import rx.android.schedulers.AndroidSchedulers;

/**
 * Created by admin on 2016/8/11.
 */
public class PhoneLookPresent implements Presenter<PhoneLiveView> {

    private PhoneLiveView phoneLiveView;

    @Override
    public void attachView(PhoneLiveView view) {
        this.phoneLiveView = view;
    }

    @Override
    public void detachView() {
        phoneLiveView = null;
    }


    public void setAttention(String userid){
        phoneLiveView.Loading_Open();
        ApplicationBase app = ApplicationBase.get(phoneLiveView.getContext());
        AnchorService service = app.getAnchorService();
        service.user_userinfo_attention(UserData.Current.mid,UserData.Current.sign,Constants.APP_TYPE,userid,"")
                .observeOn(AndroidSchedulers.mainThread())
                .subscribeOn(app.defaultSubscribeScheduler())
                .finallyDo(()->{
                    phoneLiveView.Loading_Close();
                })
                .subscribe(str -> {
                    phoneLiveView.setAttention();
                }, throwable -> {
                    CommonUtils.showToask(phoneLiveView.getContext(), throwable.getMessage());
                });

    }

}
